import { BwComTypeEnum, BwCustomComFrontTypeEnum } from '../enums'

import type { BwCustomComStructModel } from './dom'
import type { BwCustomComEmitInfoModel } from './emits'
import type { BwCustomComSlotInfoModel } from './slots'
import type { BwCallFunctionEngineOptionsModel } from '../utils/setupLogic/model'
import type {
  BwCustomComPropSetConfig,
  BwCustomComPropInfoModel,
  BwCustomComFeaturesModel,
} from './props'

export * from './dom'
export type * from './props'
export type * from './emits'
export type * from './slots'

export * from './props/enum'
export * from './emits/enum'
export * from './slots/enum'

/** 自定义组件设计信息模型 */
export interface BwCustomComDesignInfoModel {
  /** 版本号 */
  version?: string

  /** 设计器版本 */
  designVersion?: string

  /** 组件标识 */
  comCode: string

  /** 组件名称 */
  comName: string

  /** 组件外放属性 */
  comProps: Array<BwCustomComPropInfoModel> | null

  /** 组件事件 */
  emits: Array<BwCustomComEmitInfoModel> | null

  /** 组件插槽定义 */
  comSlots: Array<BwCustomComSlotInfoModel> | null

  /** 组件页面逻辑 */
  setup: Record<BwCustomComFrontTypeEnum, string>

  /** 组件样式 */
  comCss: Record<BwCustomComFrontTypeEnum, string | null>

  /** 组件DOM树 */
  structs: Record<BwCustomComFrontTypeEnum, Array<BwCustomComStructModel>>

  /** 组件外放属性值配置组件 */
  comPropsSetConfig?: BwCustomComPropSetConfig

  /** 功能点 */
  features?: BwCustomComFeaturesModel[]
  /** 变量 */
  variables?: string
}

/** 自定义组件依赖组件信息模型 */
export interface BwCustomComRelyComInfoModel {
  /** 组件标识 */
  comCode: string

  /** 组件名称 */
  comName: string

  /** 组件类型 */
  comType: BwComTypeEnum
}

export type BwGetCustomComInfoFun = (
  appCode: string,
  comCode: string
) => Promise<BwCustomComDesignInfoModel | null>

export type BwCallFunctionEngineFun = (
  data: BwCallFunctionEngineOptionsModel
) => Promise<any | null>
